local BuffModel = {}

function BuffModel:getBattleBuffIconPathByName(iconPath)
    if not iconPath then
        return nil
    end

    if string.len(iconPath) <= 0 then
    	return nil
    end

    local buffIconPath = Res.battleBuffIconPath..iconPath..".png"

    return buffIconPath
end

-- function BuffModel:getBattleBuffIconPath(buffId)
--     local buffConfig = self:getEffectConfig(buffId)
--     if not buffConfig then
--         return nil
--     end

--     if not buffConfig.icon then
--         return nil
--     end

--     local buffIconPath = self:getBattleBuffIconPathByName(buffConfig.icon)

--     return buffIconPath
-- end

function BuffModel:getBuffCfg(buff)
	local buffId = buff:buffId()
	if not BuffModel.buffCfgCache then
		BuffModel.buffCfgCache = {}
	end

	if BuffModel.buffCfgCache[buffId] then
		return BuffModel.buffCfgCache[buffId]
	else
		local buffCfg = buff:cfg()
		if buffCfg then
			local name = buffCfg:getName()
			local icon = BuffModel:getBattleBuffIconPathByName(buffCfg:getIcon())
			local desc = buffCfg:getShowDesc()
			local bShowCD = buffCfg:getbShowCD()
			local displaySort = buffCfg:getDisplaySort()
			local iconUI = BuffModel:getBattleBuffIconPathByName(buffCfg:getIconUI())
            local iconUIDesc = buffCfg:getIconUIDesc()
            local buffEffectConfig = buffCfg:getBuffEffectConfig()
			local combinationGroup = buffCfg:getCombinationGroup()
			local changeRes = buffCfg:getChangeRes()
            local sEffect = buffCfg:specialEffect()
            local bCore = buffCfg:getbCore()
            local casterId = buff:casterId()
			BuffModel.buffCfgCache[buffId] = {casterId = casterId,bCore = bCore,changeRes = changeRes,sEffect = sEffect,bShowCD = bShowCD,buffId = buffId, name = name, icon = icon, desc = desc, displaySort = displaySort, iconUI = iconUI, iconUIDesc = iconUIDesc, buffEffectConfig = buffEffectConfig, combinationGroup = combinationGroup}
			return BuffModel.buffCfgCache[buffId]
		else 
			return nil
		end
	end
end

function BuffModel:clearCache()
	BuffModel.buffCfgCache = {}
end

-- function BuffModel:getBuffNodeCache()
-- 	if not BuffModel.buffNodeCache then
-- 		BuffModel.buffNodeCache = {}
-- 	end
-- 	return BuffModel.buffNodeCache
-- end

-- function BuffModel:clearBuffNodeCache()
-- 	for k,v in pairs(BuffModel.buffNodeCache) do
-- 		v:release()
-- 	end
-- end

return BuffModel